package com.wxapp.common.constant.enums;

/**
 * @author lgl
 * @Description
 * @Datetime 2022/4/25 15:26
 * @Modified By
 */
public enum SqlMethodEnum {
    /**
     * 批量更新
     */
    BATCH_SAVE_UPDATE("batchSaveOrUpdate", "查询满足条件所有数据", "<script>\n REPLACE INTO %s %s VALUES %s\n</script>"),
    /**
     * 批量更新
     */
    BATCH_UPDATE("batchUpdate", "查询满足条件所有数据", "<script>\n<foreach collection=\"list\" item=\"item\" index=\"index\"  open=\"\" close=\"\" separator=\";\">\nupdate %s %s where %s=#{%s} %s\n</foreach>\n</script>"),
    /**
     * 批量插入
     */
    INSERT_BATCH("insertBatch", "插入一条数据（选择字段插入）", "<script>\nINSERT INTO %s %s VALUES %s\n</script>"),
    /**
     * 查询第一个
     */
    SELECT_FIRST("selectFirst", "查询满足条件一条数据", "<script>%s SELECT %s FROM %s %s limit 1 \n</script>"),
    /**
     * 判断是否存在
     */
    IS_EXIST("isExist", "查询数据是否存在", "<script>%s SELECT count(*)>=1 FROM %s %s \n</script>");
    private final String method;
    private final String desc;
    private final String sql;

    SqlMethodEnum(String method, String desc, String sql) {
        this.method = method;
        this.desc = desc;
        this.sql = sql;
    }

    public String getMethod() {
        return method;
    }

    public String getDesc() {
        return desc;
    }

    public String getSql() {
        return sql;
    }
}
